
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Provider · 《Terraform入门教程》</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="大可不加冰">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism-vsc-dark-plus.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-image-captions/image-captions.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="2.2.Terraform基础概念——状态管理.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.1.</b>
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="1.Terraform初步体验.html">
            
                <a href="1.Terraform初步体验.html">
            
                    
                        <b>1.2.</b>
                    
                    Terraform 初步体验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                        <b>1.3.</b>
                    
                    Terraform基础概念
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="2.1.Terraform基础概念——Provider.html">
            
                <a href="2.1.Terraform基础概念——Provider.html">
            
                    
                        <b>1.3.1.</b>
                    
                    Provider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="2.2.Terraform基础概念——状态管理.html">
            
                <a href="2.2.Terraform基础概念——状态管理.html">
            
                    
                        <b>1.3.2.</b>
                    
                    状态管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="3.Terraform代码的书写.html">
            
                <a href="3.Terraform代码的书写.html">
            
                    
                        <b>1.4.</b>
                    
                    Terraform 代码的书写
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="3.1.类型.html">
            
                <a href="3.1.类型.html">
            
                    
                        <b>1.4.1.</b>
                    
                    类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="3.2.配置语法.html">
            
                <a href="3.2.配置语法.html">
            
                    
                        <b>1.4.2.</b>
                    
                    配置语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="3.3.输入变量.html">
            
                <a href="3.3.输入变量.html">
            
                    
                        <b>1.4.3.</b>
                    
                    输入变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="3.4.输出值.html">
            
                <a href="3.4.输出值.html">
            
                    
                        <b>1.4.4.</b>
                    
                    输出值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="3.5.局部值.html">
            
                <a href="3.5.局部值.html">
            
                    
                        <b>1.4.5.</b>
                    
                    局部值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="3.6.资源.html">
            
                <a href="3.6.资源.html">
            
                    
                        <b>1.4.6.</b>
                    
                    资源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="3.7.数据源.html">
            
                <a href="3.7.数据源.html">
            
                    
                        <b>1.4.7.</b>
                    
                    数据源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="3.8.表达式.html">
            
                <a href="3.8.表达式.html">
            
                    
                        <b>1.4.8.</b>
                    
                    表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="3.9.重载文件.html">
            
                <a href="3.9.重载文件.html">
            
                    
                        <b>1.4.9.</b>
                    
                    重载文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="3.10.代码风格规范.html">
            
                <a href="3.10.代码风格规范.html">
            
                    
                        <b>1.4.10.</b>
                    
                    代码风格规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="3.11.checks.html">
            
                <a href="3.11.checks.html">
            
                    
                        <b>1.4.11.</b>
                    
                    Checks
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="4.Terraform模块.html">
            
                <a href="4.Terraform模块.html">
            
                    
                        <b>1.5.</b>
                    
                    Terraform 模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="4.1.创建模块.html">
            
                <a href="4.1.创建模块.html">
            
                    
                        <b>1.5.1.</b>
                    
                    创建模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="4.2.使用模块.html">
            
                <a href="4.2.使用模块.html">
            
                    
                        <b>1.5.2.</b>
                    
                    使用模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="4.3.模块元参数.html">
            
                <a href="4.3.模块元参数.html">
            
                    
                        <b>1.5.3.</b>
                    
                    模块元参数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="4.4.重构.html">
            
                <a href="4.4.重构.html">
            
                    
                        <b>1.5.4.</b>
                    
                    重构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="4.5.设计新模块的模式.html">
            
                <a href="4.5.设计新模块的模式.html">
            
                    
                        <b>1.5.5.</b>
                    
                    设计新模块的模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="5.Terraform命令行.html">
            
                <a href="5.Terraform命令行.html">
            
                    
                        <b>1.6.</b>
                    
                    Terraform 命令行
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="5.1.命令行配置文件.html">
            
                <a href="5.1.命令行配置文件.html">
            
                    
                        <b>1.6.1.</b>
                    
                    命令行配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="5.2.环境变量.html">
            
                <a href="5.2.环境变量.html">
            
                    
                        <b>1.6.2.</b>
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="5.3.资源地址.html">
            
                <a href="5.3.资源地址.html">
            
                    
                        <b>1.6.3.</b>
                    
                    资源地址
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="5.4.apply.html">
            
                <a href="5.4.apply.html">
            
                    
                        <b>1.6.4.</b>
                    
                    apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="5.5.console.html">
            
                <a href="5.5.console.html">
            
                    
                        <b>1.6.5.</b>
                    
                    console
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="5.6.destroy.html">
            
                <a href="5.6.destroy.html">
            
                    
                        <b>1.6.6.</b>
                    
                    destroy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="5.7.fmt.html">
            
                <a href="5.7.fmt.html">
            
                    
                        <b>1.6.7.</b>
                    
                    fmt
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="5.8.force-unlock.html">
            
                <a href="5.8.force-unlock.html">
            
                    
                        <b>1.6.8.</b>
                    
                    force-unlock
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="5.9.get.html">
            
                <a href="5.9.get.html">
            
                    
                        <b>1.6.9.</b>
                    
                    get
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="5.10.graph.html">
            
                <a href="5.10.graph.html">
            
                    
                        <b>1.6.10.</b>
                    
                    graph
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="5.11.import.html">
            
                <a href="5.11.import.html">
            
                    
                        <b>1.6.11.</b>
                    
                    import
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="5.12.init.html">
            
                <a href="5.12.init.html">
            
                    
                        <b>1.6.12.</b>
                    
                    init
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.13" data-path="5.13.output.html">
            
                <a href="5.13.output.html">
            
                    
                        <b>1.6.13.</b>
                    
                    output
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.14" data-path="5.14.plan.html">
            
                <a href="5.14.plan.html">
            
                    
                        <b>1.6.14.</b>
                    
                    plan
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15" data-path="5.15.providers.html">
            
                <a href="5.15.providers.html">
            
                    
                        <b>1.6.15.</b>
                    
                    providers
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.15.1" data-path="5.15.1.mirror.html">
            
                <a href="5.15.1.mirror.html">
            
                    
                        <b>1.6.15.1.</b>
                    
                    mirror
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.15.2" data-path="5.15.2.schema.html">
            
                <a href="5.15.2.schema.html">
            
                    
                        <b>1.6.15.2.</b>
                    
                    schema
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.16" data-path="5.16.refresh.html">
            
                <a href="5.16.refresh.html">
            
                    
                        <b>1.6.16.</b>
                    
                    refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.17" data-path="5.17.show.html">
            
                <a href="5.17.show.html">
            
                    
                        <b>1.6.17.</b>
                    
                    show
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18" data-path="5.18.state.html">
            
                <a href="5.18.state.html">
            
                    
                        <b>1.6.18.</b>
                    
                    state
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.18.1" data-path="5.18.1.list.html">
            
                <a href="5.18.1.list.html">
            
                    
                        <b>1.6.18.1.</b>
                    
                    list
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.2" data-path="5.18.2.mv.html">
            
                <a href="5.18.2.mv.html">
            
                    
                        <b>1.6.18.2.</b>
                    
                    mv
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.3" data-path="5.18.3.pull.html">
            
                <a href="5.18.3.pull.html">
            
                    
                        <b>1.6.18.3.</b>
                    
                    pull
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.4" data-path="5.18.4.push.html">
            
                <a href="5.18.4.push.html">
            
                    
                        <b>1.6.18.4.</b>
                    
                    push
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.5" data-path="5.18.5.replace-provider.html">
            
                <a href="5.18.5.replace-provider.html">
            
                    
                        <b>1.6.18.5.</b>
                    
                    replace-provider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.6" data-path="5.18.6.rm.html">
            
                <a href="5.18.6.rm.html">
            
                    
                        <b>1.6.18.6.</b>
                    
                    rm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.18.7" data-path="5.18.7.show.html">
            
                <a href="5.18.7.show.html">
            
                    
                        <b>1.6.18.7.</b>
                    
                    show
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.19" data-path="5.19.taint.html">
            
                <a href="5.19.taint.html">
            
                    
                        <b>1.6.19.</b>
                    
                    taint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.20" data-path="5.20.validate.html">
            
                <a href="5.20.validate.html">
            
                    
                        <b>1.6.20.</b>
                    
                    validate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.21" data-path="5.21.untaint.html">
            
                <a href="5.21.untaint.html">
            
                    
                        <b>1.6.21.</b>
                    
                    untaint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22" data-path="5.22.workspace.html">
            
                <a href="5.22.workspace.html">
            
                    
                        <b>1.6.22.</b>
                    
                    workspace
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.22.1" data-path="5.22.1.list.html">
            
                <a href="5.22.1.list.html">
            
                    
                        <b>1.6.22.1.</b>
                    
                    list
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.2" data-path="5.22.2.select.html">
            
                <a href="5.22.2.select.html">
            
                    
                        <b>1.6.22.2.</b>
                    
                    select
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.3" data-path="5.22.3.new.html">
            
                <a href="5.22.3.new.html">
            
                    
                        <b>1.6.22.3.</b>
                    
                    new
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.4" data-path="5.22.4.delete.html">
            
                <a href="5.22.4.delete.html">
            
                    
                        <b>1.6.22.4.</b>
                    
                    delete
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.22.5" data-path="5.22.5.show.html">
            
                <a href="5.22.5.show.html">
            
                    
                        <b>1.6.22.5.</b>
                    
                    show
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="6.test.html">
            
                <a href="6.test.html">
            
                    
                        <b>1.7.</b>
                    
                    Terraform Test
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="7.Aha——会心一击.html">
            
                <a href="7.Aha——会心一击.html">
            
                    
                        <b>1.8.</b>
                    
                    Aha——会心一击
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="7.1.有条件创建.html">
            
                <a href="7.1.有条件创建.html">
            
                    
                        <b>1.8.1.</b>
                    
                    有条件创建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="7.2.依赖反转.html">
            
                <a href="7.2.依赖反转.html">
            
                    
                        <b>1.8.2.</b>
                    
                    依赖反转
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="7.3.多可用区分布.html">
            
                <a href="7.3.多可用区分布.html">
            
                    
                        <b>1.8.3.</b>
                    
                    多可用区分布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="7.4.provisioner与user_data.html">
            
                <a href="7.4.provisioner与user_data.html">
            
                    
                        <b>1.8.4.</b>
                    
                    provisioner与user_data
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="7.5.destroy-provisioner中使用变量.html">
            
                <a href="7.5.destroy-provisioner中使用变量.html">
            
                    
                        <b>1.8.5.</b>
                    
                    destroy-provisioner中使用变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="7.6.利用null_resource的triggers触发其他资源更新.html">
            
                <a href="7.6.利用null_resource的triggers触发其他资源更新.html">
            
                    
                        <b>1.8.6.</b>
                    
                    利用null_resource的triggers触发其他资源更新
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="7.7.利用null_resource搭配replace_triggered_by更新无法读取的属性.html">
            
                <a href="7.7.利用null_resource搭配replace_triggered_by更新无法读取的属性.html">
            
                    
                        <b>1.8.7.</b>
                    
                    利用 null_resource 搭配 replace_triggered_by 更新无法从服务端读取内容的属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="7.8.创建资源的条件依赖另一个资源的输出时怎么办.html">
            
                <a href="7.8.创建资源的条件依赖另一个资源的输出时怎么办.html">
            
                    
                        <b>1.8.8.</b>
                    
                    创建资源的条件依赖另一个资源的输出时怎么办
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="7.9.利用create_before_destroy调整资源update执行的顺序.html">
            
                <a href="7.9.利用create_before_destroy调整资源update执行的顺序.html">
            
                    
                        <b>1.8.9.</b>
                    
                    利用 create_before_destroy 调整资源 Update 的执行顺序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="7.10.terraform与自动化.html">
            
                <a href="7.10.terraform与自动化.html">
            
                    
                        <b>1.8.10.</b>
                    
                    Terraform 与自动化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="8.CloudPosse最佳实践.html">
            
                <a href="8.CloudPosse最佳实践.html">
            
                    
                        <b>1.9.</b>
                    
                    来自CloudPosse的Terraform最佳实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="9.后记.html">
            
                <a href="9.后记.html">
            
                    
                        <b>1.10.</b>
                    
                    后记
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >Provider</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#terraform-&#x57FA;&#x7840;&#x6982;&#x5FF5;-&#x2014;&#x2014;-provider"><b>1.3.1.1. </b>Terraform &#x57FA;&#x7840;&#x6982;&#x5FF5; &#x2014;&#x2014; Provider</a></li><ul><li><span class="title-icon "></span><a href="#&#x4E0B;&#x8F7D;-provider"><b>1.3.1.1.1. </b>&#x4E0B;&#x8F7D; Provider</a></li><li><span class="title-icon "></span><a href="#&#x641C;&#x7D22;-provider"><b>1.3.1.1.2. </b>&#x641C;&#x7D22; Provider</a></li><li><span class="title-icon "></span><a href="#provider-&#x7684;&#x58F0;&#x660E;"><b>1.3.1.1.3. </b>Provider &#x7684;&#x58F0;&#x660E;</a></li><li><span class="title-icon "></span><a href="#&#x5185;&#x5EFA;-provider"><b>1.3.1.1.4. </b>&#x5185;&#x5EFA; Provider</a></li><li><span class="title-icon "></span><a href="#provider-&#x7684;&#x914D;&#x7F6E;"><b>1.3.1.1.5. </b>Provider &#x7684;&#x914D;&#x7F6E;</a></li><li><span class="title-icon "></span><a href="#&#x591A;-provider-&#x5B9E;&#x4F8B;"><b>1.3.1.1.6. </b>&#x591A; Provider &#x5B9E;&#x4F8B;</a></li><ul><li><span class="title-icon "></span><a href="#&#x9ED8;&#x8BA4;-provider-&#x914D;&#x7F6E;"><b>1.3.1.1.6.1. </b>&#x9ED8;&#x8BA4; Provider &#x914D;&#x7F6E;</a></li><li><span class="title-icon "></span><a href="#&#x5F15;&#x7528;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;"><b>1.3.1.1.6.2. </b>&#x5F15;&#x7528;&#x5907;&#x7528; Provider &#x914D;&#x7F6E;</a></li><li><span class="title-icon "></span><a href="#&#x9009;&#x62E9;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;"><b>1.3.1.1.6.3. </b>&#x9009;&#x62E9;&#x5907;&#x7528; Provider &#x914D;&#x7F6E;</a></li></ul></ul></ul></div><a href="#terraform-&#x57FA;&#x7840;&#x6982;&#x5FF5;-&#x2014;&#x2014;-provider" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="terraform-&#x57FA;&#x7840;&#x6982;&#x5FF5;-&#x2014;&#x2014;-provider"><a name="terraform-&#x57FA;&#x7840;&#x6982;&#x5FF5;-&#x2014;&#x2014;-provider" class="anchor-navigation-ex-anchor" href="#terraform-&#x57FA;&#x7840;&#x6982;&#x5FF5;-&#x2014;&#x2014;-provider"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1. Terraform &#x57FA;&#x7840;&#x6982;&#x5FF5; &#x2014;&#x2014; Provider</h1>
<p>Terraform &#x88AB;&#x8BBE;&#x8BA1;&#x6210;&#x4E00;&#x4E2A;&#x591A;&#x4E91;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x7F16;&#x6392;&#x5DE5;&#x5177;&#xFF0C;&#x4E0D;&#x50CF; CloudFormation &#x90A3;&#x6837;&#x7ED1;&#x5B9A; AWS &#x5E73;&#x53F0;&#xFF0C;Terraform &#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x7F16;&#x6392;&#x5404;&#x79CD;&#x4E91;&#x5E73;&#x53F0;&#x6216;&#x662F;&#x5176;&#x4ED6;&#x57FA;&#x7840;&#x8BBE;&#x65BD;&#x7684;&#x8D44;&#x6E90;&#x3002;Terraform &#x5B9E;&#x73B0;&#x591A;&#x4E91;&#x7F16;&#x6392;&#x7684;&#x65B9;&#x6CD5;&#x5C31;&#x662F; Provider &#x63D2;&#x4EF6;&#x673A;&#x5236;&#x3002;</p>
<figure id="fig1.3.1.1"><img src="https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605496195438-image.png" alt="Terraform&#x901A;&#x8FC7;RPC&#x8C03;&#x7528;&#x63D2;&#x4EF6;&#xFF0C;&#x63D2;&#x4EF6;&#x4EE3;&#x7801;&#x901A;&#x8FC7;&#x8C03;&#x7528;SDK&#x64CD;&#x4F5C;&#x8FDC;&#x7A0B;&#x8D44;&#x6E90;"><figcaption>&#x56FE; 1.3.1/1 - Terraform&#x901A;&#x8FC7;RPC&#x8C03;&#x7528;&#x63D2;&#x4EF6;&#xFF0C;&#x63D2;&#x4EF6;&#x4EE3;&#x7801;&#x901A;&#x8FC7;&#x8C03;&#x7528;SDK&#x64CD;&#x4F5C;&#x8FDC;&#x7A0B;&#x8D44;&#x6E90;</figcaption></figure>
<p>Terraform &#x4F7F;&#x7528;&#x7684;&#x662F; HashiCorp &#x81EA;&#x7814;&#x7684; <a href="https://github.com/hashicorp/go-plugin" target="_blank"><code>go-plugin</code> &#x5E93;</a>)&#xFF0C;&#x672C;&#x8D28;&#x4E0A;&#x5404;&#x4E2A; Provider &#x63D2;&#x4EF6;&#x90FD;&#x662F;&#x72EC;&#x7ACB;&#x7684;&#x8FDB;&#x7A0B;&#xFF0C;&#x4E0E; Terraform &#x8FDB;&#x7A0B;&#x4E4B;&#x95F4;&#x901A;&#x8FC7; Rpc &#x8FDB;&#x884C;&#x8C03;&#x7528;&#x3002;Terraform &#x5F15;&#x64CE;&#x9996;&#x5148;&#x8BFB;&#x53D6;&#x5E76;&#x5206;&#x6790;&#x7528;&#x6237;&#x7F16;&#x5199;&#x7684; Terraform &#x4EE3;&#x7801;&#xFF0C;&#x5F62;&#x6210;&#x4E00;&#x4E2A;&#x7531; <code>data</code> &#x4E0E; <code>resource</code> &#x7EC4;&#x6210;&#x7684;&#x56FE;(Graph)&#xFF0C;&#x518D;&#x901A;&#x8FC7; Rpc &#x8C03;&#x7528;&#x8FD9;&#x4E9B; <code>data</code> &#x4E0E; <code>resource</code> &#x6240;&#x5BF9;&#x5E94;&#x7684; Provider &#x63D2;&#x4EF6;&#xFF1B;Provider &#x63D2;&#x4EF6;&#x7684;&#x7F16;&#x5199;&#x8005;&#x6839;&#x636E; Terraform &#x6240;&#x5236;&#x5B9A;&#x7684;&#x63D2;&#x4EF6;&#x6846;&#x67B6;&#x6765;&#x5B9A;&#x4E49;&#x5404;&#x79CD; <code>data</code> &#x548C; <code>resource</code>&#xFF0C;&#x5E76;&#x5B9E;&#x73B0;&#x76F8;&#x5E94;&#x7684; CRUD &#x65B9;&#x6CD5;&#xFF1B;&#x5728;&#x5B9E;&#x73B0;&#x8FD9;&#x4E9B; CRUD &#x65B9;&#x6CD5;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x76EE;&#x6807;&#x5E73;&#x53F0;&#x63D0;&#x4F9B;&#x7684; SDK&#xFF0C;&#x6216;&#x662F;&#x76F4;&#x63A5;&#x901A;&#x8FC7;&#x8C03;&#x7528; Http(s) API&#x6765;&#x64CD;&#x4F5C;&#x76EE;&#x6807;&#x5E73;&#x53F0;&#x3002;</p>
<h2 id="&#x4E0B;&#x8F7D;-provider"><a name="&#x4E0B;&#x8F7D;-provider" class="anchor-navigation-ex-anchor" href="#&#x4E0B;&#x8F7D;-provider"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.1. &#x4E0B;&#x8F7D; Provider</h2>
<p>&#x6211;&#x4EEC;&#x5728;&#x7B2C;&#x4E00;&#x7AE0;&#x7684;&#x5C0F;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x5199;&#x5B8C;&#x4EE3;&#x7801;&#x540E;&#x5728; <code>apply</code> &#x4E4B;&#x524D;&#xFF0C;&#x9996;&#x5148;&#x6211;&#x4EEC;&#x6267;&#x884C;&#x4E86;&#x4E00;&#x6B21;<code>terraform init</code>&#x3002;<code>terraform init</code>&#x4F1A;&#x5206;&#x6790;&#x4EE3;&#x7801;&#x4E2D;&#x6240;&#x4F7F;&#x7528;&#x5230;&#x7684; Provider&#xFF0C;&#x5E76;&#x5C1D;&#x8BD5;&#x4E0B;&#x8F7D; Provider &#x63D2;&#x4EF6;&#x5230;&#x672C;&#x5730;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x89C2;&#x5BDF;&#x6267;&#x884C;&#x5B8C;&#x7B2C;&#x4E00;&#x7AE0;&#x4F8B;&#x5B50;&#x7684;&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x53D1;&#x73B0;&#x6709;&#x4E00;&#x4E2A; <code>.terraform</code> &#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x6211;&#x4EEC;&#x6240;&#x4F7F;&#x7528;&#x7684; AWS Provider &#x63D2;&#x4EF6;&#x5C31;&#x88AB;&#x4E0B;&#x8F7D;&#x5B89;&#x88C5;&#x5728;&#x91CC;&#x9762;&#x3002;</p>
<pre class="language-"><code class="lang-bash">.terraform
&#x2514;&#x2500;&#x2500; providers
    &#x2514;&#x2500;&#x2500; registry.terraform.io
        &#x2514;&#x2500;&#x2500; hashicorp
            &#x2514;&#x2500;&#x2500; aws
                &#x2514;&#x2500;&#x2500; <span class="token number">5.37</span>.0
                    &#x2514;&#x2500;&#x2500; windows_amd64
                        &#x2514;&#x2500;&#x2500; terraform-provider-aws_v5.37.0_x5.exe
</code></pre>
<p>&#x6709;&#x7684;&#x65F6;&#x5019;&#x4E0B;&#x8F7D;&#x67D0;&#x4E9B; Provider &#x4F1A;&#x975E;&#x5E38;&#x7F13;&#x6162;&#xFF0C;&#x6216;&#x662F;&#x5728;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x4E2D;&#x5B58;&#x5728;&#x8BB8;&#x591A;&#x7684; Terraform &#x9879;&#x76EE;&#xFF0C;&#x6BCF;&#x4E2A;&#x9879;&#x76EE;&#x90FD;&#x4FDD;&#x6709;&#x81EA;&#x5DF1;&#x72EC;&#x7ACB;&#x7684;&#x63D2;&#x4EF6;&#x6587;&#x4EF6;&#x5939;&#x975E;&#x5E38;&#x6D6A;&#x8D39;&#x78C1;&#x76D8;&#xFF0C;&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x63D2;&#x4EF6;&#x7F13;&#x5B58;&#x3002;</p>
<p>&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x53EF;&#x4EE5;&#x542F;&#x7528;&#x63D2;&#x4EF6;&#x7F13;&#x5B58;&#xFF1A;</p>
<p><strong>&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;</strong>&#x662F;&#x914D;&#x7F6E; <code>TF_PLUGIN_CACHE_DIR</code> &#x8FD9;&#x4E2A;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token builtin class-name">export</span> <span class="token assign-left variable">TF_PLUGIN_CACHE_DIR</span><span class="token operator">=</span><span class="token string">&quot;<span class="token environment constant">$HOME</span>/.terraform.d/plugin-cache&quot;</span>
</code></pre>
<p><strong>&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x6CD5;</strong>&#x662F;&#x4F7F;&#x7528; CLI &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3002;Windows &#x4E0B;&#x662F;&#x5728;&#x76F8;&#x5173;&#x7528;&#x6237;&#x7684; <code>%APPDATA%</code> &#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x540D;&#x4E3A; <code>&quot;terraform.rc&quot;</code> &#x7684;&#x6587;&#x4EF6;&#xFF0C;Macos &#x548C; Linux &#x7528;&#x6237;&#x5219;&#x662F;&#x5728;&#x7528;&#x6237;&#x7684; <code>home</code> &#x4E0B;&#x521B;&#x5EFA;&#x540D;&#x4E3A; <code>&quot;.terraformrc&quot;</code> &#x7684;&#x6587;&#x4EF6;&#x3002;&#x5728;&#x6587;&#x4EF6;&#x4E2D;&#x914D;&#x7F6E;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-config">plugin_cache_dir = &quot;$HOME/.terraform.d/plugin-cache&quot;
</code></pre>
<p>&#x5F53;&#x542F;&#x7528;&#x63D2;&#x4EF6;&#x7F13;&#x5B58;&#x4E4B;&#x540E;&#xFF0C;&#x6BCF;&#x5F53;&#x6267;&#x884C; <code>terraform init</code> &#x547D;&#x4EE4;&#x65F6;&#xFF0C;Terraform &#x5F15;&#x64CE;&#x4F1A;&#x9996;&#x5148;&#x68C0;&#x67E5;&#x671F;&#x671B;&#x4F7F;&#x7528;&#x7684;&#x63D2;&#x4EF6;&#x5728;&#x7F13;&#x5B58;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#xFF0C;&#x5982;&#x679C;&#x5B58;&#x5728;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x4F1A;&#x5C06;&#x7F13;&#x5B58;&#x7684;&#x63D2;&#x4EF6;&#x62F7;&#x8D1D;&#x5230;&#x5F53;&#x524D;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;&#x4E0B;&#x7684; <code>.terraform</code> &#x6587;&#x4EF6;&#x5939;&#x5185;&#x3002;&#x5982;&#x679C;&#x63D2;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x4ECD;&#x7136;&#x4F1A;&#x50CF;&#x4E4B;&#x524D;&#x90A3;&#x6837;&#x4E0B;&#x8F7D;&#x63D2;&#x4EF6;&#xFF0C;&#x5E76;&#x9996;&#x5148;&#x4FDD;&#x5B58;&#x5728;&#x63D2;&#x4EF6;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#xFF0C;&#x968F;&#x540E;&#x518D;&#x4ECE;&#x63D2;&#x4EF6;&#x6587;&#x4EF6;&#x5939;&#x62F7;&#x8D1D;&#x5230;&#x5F53;&#x524D;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;&#x4E0B;&#x7684; <code>.terraform</code> &#x6587;&#x4EF6;&#x5939;&#x5185;&#x3002;&#x4E3A;&#x4E86;&#x5C3D;&#x91CF;&#x907F;&#x514D;&#x540C;&#x4E00;&#x4EFD;&#x63D2;&#x4EF6;&#x88AB;&#x4FDD;&#x5B58;&#x591A;&#x6B21;&#xFF0C;&#x53EA;&#x8981;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x63D0;&#x4F9B;&#x652F;&#x6301;&#xFF0C;Terraform &#x5C31;&#x4F1A;&#x4F7F;&#x7528;&#x7B26;&#x53F7;&#x8FDE;&#x63A5;&#x800C;&#x4E0D;&#x662F;&#x5B9E;&#x9645;&#x4ECE;&#x63D2;&#x4EF6;&#x7F13;&#x5B58;&#x76EE;&#x5F55;&#x62F7;&#x8D1D;&#x5230;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;&#x3002;</p>
<p><strong>&#x9700;&#x8981;&#x7279;&#x522B;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;Windows &#x7CFB;&#x7EDF;&#x4E0B; <code>plugin_cache_dir</code> &#x7684;&#x8DEF;&#x5F84;&#x4E5F;&#x5FC5;&#x987B;&#x4F7F;&#x7528; <code>/</code> &#x4F5C;&#x4E3A;&#x5206;&#x9694;&#x7B26;&#xFF0C;&#x5E94;&#x4F7F;&#x7528; <code>C:/somefolder/plugin_cahce</code> &#x800C;&#x4E0D;&#x662F; <code>C:\somefolder\plugin_cache</code></strong></p>
<p>Terraform &#x5F15;&#x64CE;&#x6C38;&#x8FDC;&#x4E0D;&#x4F1A;&#x4E3B;&#x52A8;&#x5220;&#x9664;&#x7F13;&#x5B58;&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x7F13;&#x5B58;&#x6587;&#x4EF6;&#x5939;&#x7684;&#x5C3A;&#x5BF8;&#x53EF;&#x80FD;&#x4F1A;&#x968F;&#x7740;&#x65F6;&#x95F4;&#x800C;&#x589E;&#x957F;&#x5230;&#x975E;&#x5E38;&#x5927;&#xFF0C;&#x8FD9;&#x65F6;&#x9700;&#x8981;&#x624B;&#x5DE5;&#x6E05;&#x7406;&#x3002;</p>
<h2 id="&#x641C;&#x7D22;-provider"><a name="&#x641C;&#x7D22;-provider" class="anchor-navigation-ex-anchor" href="#&#x641C;&#x7D22;-provider"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.2. &#x641C;&#x7D22; Provider</h2>
<p>&#x60F3;&#x8981;&#x4E86;&#x89E3;&#x6709;&#x54EA;&#x4E9B;&#x88AB;&#x5B98;&#x65B9;&#x63A5;&#x7EB3;&#x7684; Provider&#xFF0C;&#x5C31;&#x662F;&#x524D;&#x5F80;<a href="https://registry.terraform.io/browse/providers" target="_blank">registry.terraform.io</a>&#x8FDB;&#x884C;&#x641C;&#x7D22;&#xFF1A;</p>
<figure id="fig1.3.1.2"><img src="https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-19/1605799350775-image.png" alt="registry.terraform.io&#x4E0A;&#x7684;&#x63D2;&#x4EF6;&#x9875;&#x9762;"><figcaption>&#x56FE; 1.3.1/2 - registry.terraform.io&#x4E0A;&#x7684;&#x63D2;&#x4EF6;&#x9875;&#x9762;</figcaption></figure>
<figure id="fig1.3.1.3"><img src="https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605498907942-image.png" alt="registry.terraform.io&#x7684;&#x641C;&#x7D22;&#x9875;&#x9762;"><figcaption>&#x56FE; 1.3.1/3 - registry.terraform.io&#x7684;&#x641C;&#x7D22;&#x9875;&#x9762;</figcaption></figure>
<p>&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x76F8;&#x5173; Provider &#x5982;&#x4F55;&#x58F0;&#x660E;&#xFF0C;&#x4EE5;&#x53CA;&#x76F8;&#x5173; <code>data</code>&#x3001;<code>resource</code> &#x7684;&#x4F7F;&#x7528;&#x8BF4;&#x660E;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x5728; registry &#x4E0A;&#x67E5;&#x9605;&#x5230;&#x76F8;&#x5173;&#x6587;&#x6863;&#x3002;</p>
<p><a href="https://registry.terraform.io" target="_blank"><code>registry.terraform.io</code></a> &#x4E0D;&#x4F46;&#x53EF;&#x4EE5;&#x67E5;&#x8BE2; Provider&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x53D1;&#x5E03; Provider&#xFF1B;&#x5E76;&#x4E14;&#x5B83;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x67E5;&#x8BE2;&#x548C;&#x53D1;&#x5E03;&#x6A21;&#x5757;(Module)&#xFF0C;&#x4E0D;&#x8FC7;&#x6A21;&#x5757;&#x5C06;&#x662F;&#x6211;&#x4EEC;&#x540E;&#x7EED;&#x7BC7;&#x7AE0;&#x8BA8;&#x8BBA;&#x7684;&#x8BDD;&#x9898;&#x3002;</p>
<h2 id="provider-&#x7684;&#x58F0;&#x660E;"><a name="provider-&#x7684;&#x58F0;&#x660E;" class="anchor-navigation-ex-anchor" href="#provider-&#x7684;&#x58F0;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.3. Provider &#x7684;&#x58F0;&#x660E;</h2>
<p>&#x4E00;&#x7EC4; Terraform &#x4EE3;&#x7801;&#x8981;&#x88AB;&#x6267;&#x884C;&#xFF0C;&#x76F8;&#x5173;&#x7684; Provider &#x5FC5;&#x987B;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x88AB;&#x58F0;&#x660E;&#x3002;&#x4E0D;&#x5C11;&#x7684; Provider &#x5728;&#x58F0;&#x660E;&#x65F6;&#x9700;&#x8981;&#x4F20;&#x5165;&#x4E00;&#x4E9B;&#x5173;&#x952E;&#x4FE1;&#x606F;&#x624D;&#x80FD;&#x88AB;&#x4F7F;&#x7528;&#xFF0C;&#x4F8B;&#x5982;&#x6211;&#x4EEC;&#x5728;&#x7B2C;&#x4E00;&#x7AE0;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x5FC5;&#x987B;&#x7ED9;&#x51FA;&#x8BBF;&#x95EE;&#x5BC6;&#x94A5;&#x4EE5;&#x53CA;&#x671F;&#x671B;&#x6267;&#x884C;&#x7684; AWS &#x533A;&#x57DF;&#xFF08;Region&#xFF09;&#x4FE1;&#x606F;&#x3002;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">terraform</span> <span class="token punctuation">{</span>
  <span class="token keyword">required_providers</span> <span class="token punctuation">{</span>
    <span class="token property">aws</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
      <span class="token property">source</span> <span class="token punctuation">=</span> <span class="token string">&quot;hashicorp/aws&quot;</span>
      <span class="token property">version</span> <span class="token punctuation">=</span> <span class="token string">&quot;~&gt;5.0&quot;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">provider<span class="token type variable"> &quot;aws&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">access_key</span>                  <span class="token punctuation">=</span> <span class="token string">&quot;test&quot;</span>
  <span class="token property">secret_key</span>                  <span class="token punctuation">=</span> <span class="token string">&quot;test&quot;</span>
  <span class="token property">region</span>                      <span class="token punctuation">=</span> <span class="token string">&quot;us-east-1&quot;</span>
  <span class="token property">s3_use_path_style</span>           <span class="token punctuation">=</span> <span class="token boolean">false</span>
  <span class="token property">skip_credentials_validation</span> <span class="token punctuation">=</span> <span class="token boolean">true</span>
  <span class="token property">skip_metadata_api_check</span>     <span class="token punctuation">=</span> <span class="token boolean">true</span>
  <span class="token property">skip_requesting_account_id</span>  <span class="token punctuation">=</span> <span class="token boolean">true</span>

  <span class="token keyword">endpoints</span> <span class="token punctuation">{</span>
    <span class="token property">apigateway</span>     <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">apigatewayv2</span>   <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">cloudformation</span> <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">cloudwatch</span>     <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">dynamodb</span>       <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">ec2</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">es</span>             <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">elasticache</span>    <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">firehose</span>       <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">iam</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">kinesis</span>        <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">lambda</span>         <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">rds</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">redshift</span>       <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">route53</span>        <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">s3</span>             <span class="token punctuation">=</span> <span class="token string">&quot;http://s3.localhost.localstack.cloud:4566&quot;</span>
    <span class="token property">secretsmanager</span> <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">ses</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">sns</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">sqs</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">ssm</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">stepfunctions</span>  <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
    <span class="token property">sts</span>            <span class="token punctuation">=</span> <span class="token string">&quot;http://localhost:4566&quot;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728;&#x8FD9;&#x6BB5; Provider &#x58F0;&#x660E;&#x4E2D;&#xFF0C;&#x9996;&#x5148;&#x5728; <code>terraform</code> &#x5757;&#x7684; <code>required_providers</code> &#x91CC;&#x58F0;&#x660E;&#x4E86;&#x672C;&#x6BB5;&#x4EE3;&#x7801;&#x5FC5;&#x987B;&#x8981;&#x540D;&#x4E3A; <code>aws</code> &#x7684; Provider &#x624D;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#xFF0C;<code>source = &quot;hashicorp/aws&quot;</code>&#x8FD9;&#x4E00;&#x884C;&#x58F0;&#x660E;&#x4E86; <code>aws</code> &#x8FD9;&#x4E2A;&#x63D2;&#x4EF6;&#x7684;&#x6E90;&#x5730;&#x5740;(Source Address)&#x3002;&#x4E00;&#x4E2A;&#x6E90;&#x5730;&#x5740;&#x662F;&#x5168;&#x7403;&#x552F;&#x4E00;&#x7684;&#xFF0C;&#x5B83;&#x6307;&#x793A;&#x4E86; Terraform &#x5982;&#x4F55;&#x4E0B;&#x8F7D;&#x8BE5;&#x63D2;&#x4EF6;&#x3002;&#x4E00;&#x4E2A;&#x6E90;&#x5730;&#x5740;&#x7531;&#x4E09;&#x90E8;&#x5206;&#x7EC4;&#x6210;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token punctuation">[</span>&lt;HOSTNAME&gt;/<span class="token punctuation">]</span>&lt;NAMESPACE&gt;/&lt;TYPE&gt;
</code></pre>
<p><code>Hostname</code> &#x662F;&#x9009;&#x586B;&#x7684;&#xFF0C;&#x9ED8;&#x8BA4;&#x662F;&#x5B98;&#x65B9;&#x7684; <code>registry.terraform.io</code>&#xFF0C;&#x8BFB;&#x8005;&#x4E5F;&#x53EF;&#x4EE5;&#x6784;&#x5EFA;&#x81EA;&#x5DF1;&#x79C1;&#x6709;&#x7684;Terraform&#x4ED3;&#x5E93;&#x3002;<code>Namespace</code> &#x662F;&#x5728; Terraform &#x4ED3;&#x5E93;&#x5185;&#x6CE8;&#x518C;&#x7684;&#x7EC4;&#x7EC7;&#x540D;&#xFF0C;&#x8FD9;&#x4EE3;&#x8868;&#x4E86;&#x53D1;&#x5E03;&#x548C;&#x7EF4;&#x62A4;&#x63D2;&#x4EF6;&#x7684;&#x7EC4;&#x7EC7;&#x6216;&#x662F;&#x4E2A;&#x4EBA;&#x3002;<code>Type</code> &#x662F;&#x4EE3;&#x8868;&#x63D2;&#x4EF6;&#x7684;&#x4E00;&#x4E2A;&#x77ED;&#x540D;&#xFF0C;&#x5728;&#x7279;&#x5B9A;&#x7684; <code>HostName</code>/<code>Namespace</code> &#x4E0B; <code>Type</code> &#x5FC5;&#x987B;&#x552F;&#x4E00;&#x3002;</p>
<p><code>required_providers</code> &#x4E2D;&#x7684;&#x63D2;&#x4EF6;&#x58F0;&#x660E;&#x8FD8;&#x58F0;&#x660E;&#x4E86;&#x8BE5;&#x6E90;&#x7801;&#x6240;&#x9700;&#x8981;&#x7684;&#x63D2;&#x4EF6;&#x7684;&#x7248;&#x672C;&#x7EA6;&#x675F;&#xFF0C;&#x5728;&#x4F8B;&#x5B50;&#x91CC;&#x5C31;&#x662F; <code>version = &quot;~&gt;5.0&quot;</code>&#x3002;Terraform &#x63D2;&#x4EF6;&#x7684;&#x7248;&#x672C;&#x53F7;&#x91C7;&#x7528; <code>MAJOR.MINOR.PATCH</code> &#x7684;&#x8BED;&#x4E49;&#x5316;&#x683C;&#x5F0F;&#xFF0C;&#x7248;&#x672C;&#x7EA6;&#x675F;&#x901A;&#x5E38;&#x4F7F;&#x7528;&#x64CD;&#x4F5C;&#x7B26;&#x548C;&#x7248;&#x672C;&#x53F7;&#x8868;&#x8FBE;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#xFF0C;&#x6761;&#x4EF6;&#x4E4B;&#x95F4;&#x53EF;&#x4EE5;&#x7528;&#x9017;&#x53F7;&#x62FC;&#x63A5;&#xFF0C;&#x8868;&#x8FBE; <code>AND</code> &#x5173;&#x8054;&#xFF0C;&#x4F8B;&#x5982; <code>&quot;&gt;= 1.2.0, &lt; 2.0.0&quot;</code>&#x3002;&#x53EF;&#x4EE5;&#x91C7;&#x7528;&#x7684;&#x64CD;&#x4F5C;&#x7B26;&#x6709;&#xFF1A;</p>
<ul>
<li><code>=</code>(&#x6216;&#x8005;&#x4E0D;&#x52A0; <code>=</code>&#xFF0C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7248;&#x672C;&#x53F7;)&#xFF1A;&#x53EA;&#x5141;&#x8BB8;&#x7279;&#x5B9A;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x4E0D;&#x5141;&#x8BB8;&#x4E0E;&#x5176;&#x4ED6;&#x6761;&#x4EF6;&#x5408;&#x5E76;&#x4F7F;&#x7528;</li>
<li><code>!=</code>&#xFF1A;&#x4E0D;&#x5141;&#x8BB8;&#x7279;&#x5B9A;&#x7248;&#x672C;&#x53F7;</li>
<li><code>\&gt;</code>,<code>&gt;=</code>,<code>&lt;</code>,<code>&lt;=</code>&#xFF1A;&#x4E0E;&#x7279;&#x5B9A;&#x7248;&#x672C;&#x53F7;&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x5927;&#x4E8E;&#x3001;&#x5927;&#x4E8E;&#x7B49;&#x4E8E;&#x3001;&#x5C0F;&#x4E8E;&#x3001;&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E;</li>
<li><code>~&gt;</code>&#xFF1A;&#x53EA;&#x5141;&#x8BB8; <em>&#x6700;&#x53F3;&#x8FB9;</em> &#x7684;&#x7248;&#x672C;&#x53F7;&#x589E;&#x52A0;&#x3002;&#x8FD9;&#x79CD;&#x683C;&#x5F0F;&#x88AB;&#x79F0;&#x4E3A; <em>&#x60B2;&#x89C2;&#x7EA6;&#x675F;</em> &#x64CD;&#x4F5C;&#x7B26;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x8981;&#x5141;&#x8BB8;&#x5728;&#x7279;&#x5B9A;&#x7684; <code>MINOR</code> &#x7248;&#x672C;&#x4E2D;&#x5141;&#x8BB8;&#x65B0;&#x7684; <code>PATCH</code> &#x7248;&#x672C;&#xFF1A;<ul>
<li><code>~&gt; 1.0.4</code>&#xFF1A;&#x5141;&#x8BB8; Terraform &#x5B89;&#x88C5; <code>1.0.5</code> &#x548C; <code>1.0.10</code>&#xFF0C;&#x4F46;&#x4E0D;&#x5141;&#x8BB8; <code>1.1.0</code>&#x3002;</li>
<li><code>~&gt; 1.1</code>&#xFF1A;&#x5141;&#x8BB8; Terraform &#x5B89;&#x88C5; <code>1.2</code> &#x548C; <code>1.10</code>&#xFF0C;&#x4F46;&#x4E0D;&#x5141;&#x8BB8; <code>2.0</code>&#x3002;</li>
</ul>
</li>
</ul>
<p>Terraform &#x4F1A;&#x68C0;&#x67E5;&#x5F53;&#x524D;&#x5DE5;&#x4F5C;&#x73AF;&#x5883;&#x6216;&#x662F;&#x63D2;&#x4EF6;&#x7F13;&#x5B58;&#x4E2D;&#x662F;&#x5426;&#x5B58;&#x5728;&#x6EE1;&#x8DB3;&#x7248;&#x672C;&#x7EA6;&#x675F;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x90A3;&#x4E48; Terraform &#x4F1A;&#x5C1D;&#x8BD5;&#x4E0B;&#x8F7D;&#x3002;&#x5982;&#x679C; Terraform &#x65E0;&#x6CD5;&#x83B7;&#x5F97;&#x4EFB;&#x4F55;&#x6EE1;&#x8DB3;&#x7248;&#x672C;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x7684;&#x63D2;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x4F1A;&#x62D2;&#x7EDD;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x4EFB;&#x4F55;&#x540E;&#x7EED;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x7528;&#x6DFB;&#x52A0;&#x540E;&#x7F00;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x58F0;&#x660E;&#x9884;&#x89C8;&#x7248;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<code>1.2.0-beta</code>&#x3002;&#x9884;&#x89C8;&#x7248;&#x53EA;&#x80FD;&#x901A;&#x8FC7; <code>&quot;=&quot;</code> &#x64CD;&#x4F5C;&#x7B26;(&#x6216;&#x662F;&#x5FFD;&#x7565;&#x64CD;&#x4F5C;&#x7B26;)&#x540E;&#x63A5;&#x660E;&#x786E;&#x7684;&#x7248;&#x672C;&#x53F7;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x6307;&#x5B9A;&#xFF0C;&#x4E0D;&#x53EF;&#x4EE5;&#x4E0E;<code>&gt;=</code>&#x3001;<code>~&gt;</code>&#x7B49;&#x642D;&#x914D;&#x4F7F;&#x7528;&#x3002;</p>
<ul>
<li>&#x5F53;&#x4F9D;&#x8D56;&#x7B2C;&#x4E09;&#x65B9;&#x6A21;&#x5757;&#x65F6;&#xFF0C;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x7279;&#x5B9A;&#x7248;&#x672C;&#xFF0C;&#x4EE5;&#x786E;&#x4FDD;&#x53EA;&#x5728;&#x60A8;&#x9700;&#x8981;&#x7684;&#x65F6;&#x5019;&#x8FDB;&#x884C;&#x66F4;&#x65B0;&#x3002;</li>
<li>&#x5BF9;&#x4E8E;&#x5728;&#x60A8;&#x7684;&#x7EC4;&#x7EC7;&#x5185;&#x7EF4;&#x62A4;&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x5982;&#x679C;&#x4E00;&#x81F4;&#x4F7F;&#x7528;&#x8BED;&#x4E49;&#x7248;&#x672C;&#x63A7;&#x5236;&#xFF0C;&#x6216;&#x8005;&#x6709;&#x4E00;&#x4E2A;&#x5B9A;&#x4E49;&#x826F;&#x597D;&#x7684;&#x53D1;&#x5E03;&#x6D41;&#x7A0B;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x4E0D;&#x5FC5;&#x8981;&#x7684;&#x66F4;&#x65B0;&#xFF0C;&#x90A3;&#x4E48;&#x6307;&#x5B9A;&#x7248;&#x672C;&#x8303;&#x56F4;&#x53EF;&#x80FD;&#x662F;&#x5408;&#x9002;&#x7684;&#x3002;</li>
<li>&#x53EF;&#x91CD;&#x7528;&#x7684;&#x6A21;&#x5757;&#x5E94;&#x4EC5;&#x9650;&#x5236;&#x5176; Terraform &#x548C; Provider &#x7684;&#x6700;&#x4F4E;&#x5141;&#x8BB8;&#x7248;&#x672C;&#xFF0C;&#x4F8B;&#x5982; <code>&gt;= 0.12.0</code>&#x3002;&#x8FD9;&#x6709;&#x52A9;&#x4E8E;&#x907F;&#x514D;&#x5DF2;&#x77E5;&#x7684;&#x4E0D;&#x517C;&#x5BB9;&#x6027;&#xFF0C;&#x540C;&#x65F6;&#x5141;&#x8BB8;&#x6A21;&#x5757;&#x7684;&#x7528;&#x6237;&#x5728;&#x4E0D;&#x6539;&#x53D8;&#x6A21;&#x5757;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x5347;&#x7EA7;&#x5230; Terraform &#x7684;&#x65B0;&#x7248;&#x672C;&#x3002;  </li>
<li>&#x6839;&#x6A21;&#x5757;&#x5E94;&#x4F7F;&#x7528; <code>~&gt;</code> &#x7EA6;&#x675F;&#x4E3A;&#x5B83;&#x4EEC;&#x4F9D;&#x8D56;&#x7684;&#x6BCF;&#x4E2A; Provider &#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x4E0B;&#x9650;&#x548C;&#x4E0A;&#x9650;&#x7248;&#x672C;&#x3002;</li>
</ul>
<p>&#x4EE5;&#x4E0A;&#x5EFA;&#x8BAE;&#x6765;&#x81EA;&#x4E8E; <a href="https://developer.hashicorp.com/terraform/language/expressions/version-constraints#best-practices" target="_blank">HashiCorp &#x5B98;&#x65B9;&#x6587;&#x6863;</a>&#xFF0C;&#x7B14;&#x8005;&#x4E2A;&#x4EBA;&#x7ED9;&#x51FA;&#x4E00;&#x6761;&#x4E2A;&#x4EBA;&#x5EFA;&#x8BAE;&#xFF1A;</p>
<ul>
<li>&#x53EF;&#x590D;&#x7528;&#x7684;&#x6A21;&#x5757;&#x4E0D;&#x4F46;&#x5E94;&#x8BE5;&#x9650;&#x5236; Provider &#x7684;&#x6700;&#x4F4E;&#x7248;&#x672C;&#xFF0C;&#x540C;&#x65F6;&#x4E5F;&#x5E94;&#x8BE5;&#x9650;&#x5236; Provider &#x7684; <code>MAJOR</code> &#x7248;&#x672C;&#x3002;&#x4F8B;&#x5982;&#xFF0C;<code>&gt;= 1.5.0, &lt; 2.0</code>&#x3002;&#x8FD9;&#x6837;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x5728; Provider &#x7684; <code>MAJOR</code> &#x7248;&#x672C;&#x5347;&#x7EA7;&#x65F6;&#xFF0C;&#x56E0;&#x4E3A;&#x4E0D;&#x517C;&#x5BB9;&#x6027;&#x5BFC;&#x81F4;&#x7684;&#x95EE;&#x9898;&#xFF0C;Provider &#x7684; <code>MAJOR</code> &#x7248;&#x672C;&#x5347;&#x7EA7;&#x901A;&#x5E38;&#x4F1A;&#x4F34;&#x968F;&#x7740;&#x4E0D;&#x517C;&#x5BB9;&#x7684;&#x6539;&#x52A8;&#xFF0C;&#x4E0D;&#x5E94;&#x8BE5;&#x5728;&#x672A;&#x52A0;&#x6D4B;&#x8BD5;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x8F7B;&#x6613;&#x5347;&#x7EA7;&#x3002;</li>
</ul>
<h2 id="&#x5185;&#x5EFA;-provider"><a name="&#x5185;&#x5EFA;-provider" class="anchor-navigation-ex-anchor" href="#&#x5185;&#x5EFA;-provider"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.4. &#x5185;&#x5EFA; Provider</h2>
<p>&#x7EDD;&#x5927;&#x591A;&#x6570; Provider &#x662F;&#x4EE5;&#x63D2;&#x4EF6;&#x5F62;&#x5F0F;&#x5355;&#x72EC;&#x5206;&#x53D1;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x76EE;&#x524D;&#x6709;&#x4E00;&#x4E2A; Provider &#x662F;&#x5185;&#x5EFA;&#x4E8E;Terraform&#x4E3B;&#x8FDB;&#x7A0B;&#x4E2D;&#x7684;&#xFF0C;&#x90A3;&#x5C31;&#x662F; <code>terraform_remote_state</code> data source&#x3002;&#x8BE5; Provider &#x7531;&#x4E8E;&#x662F;&#x5185;&#x5EFA;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4F7F;&#x7528;&#x65F6;&#x4E0D;&#x9700;&#x8981;&#x5728; <code>terraform</code> &#x4E2D;&#x58F0;&#x660E; <code>required_providers</code>&#x3002;&#x8FD9;&#x4E2A;&#x5185;&#x5EFA;Provider&#x7684;&#x6E90;&#x5730;&#x5740;&#x662F; <code>terraform.io/builtin/terraform</code>&#x3002;&#x8FD9;&#x4E2A;&#x5730;&#x5740;&#x6709;&#x65F6;&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x5728; Terraform &#x7684;&#x9519;&#x8BEF;&#x6D88;&#x606F;&#x548C;&#x5176;&#x4ED6;&#x8F93;&#x51FA;&#x4E2D;&#xFF0C;&#x4EE5;&#x4FBF;&#x65E0;&#x6B67;&#x4E49;&#x5730;&#x5F15;&#x7528;&#x5185;&#x5EFA; Provider&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x5047;&#x8BBE;&#x7684;&#x7B2C;&#x4E09;&#x65B9;&#x63D0;&#x4F9B;&#x8005;&#xFF0C;&#x5176;&#x7C7B;&#x578B;&#x540D;&#x79F0;&#x4E3A; &quot;terraform&quot;&#x3002;</p>
<p>&#x8FD8;&#x5B58;&#x5728;&#x4E00;&#x4E2A;&#x6E90;&#x5730;&#x5740;&#x4E3A; <code>hashicorp/terraform</code> &#x7684; Provider&#xFF0C;&#x8FD9;&#x662F;&#x73B0;&#x5728;&#x5185;&#x7F6E; Provider &#x7684;&#x65E7;&#x7248;&#x672C;&#xFF0C;&#x88AB; Terraform &#x7684;&#x65E7;&#x7248;&#x672C;&#x4F7F;&#x7528;&#x3002;<code>hashicorp/terraform</code> &#x4E0E; Terraform v0.11 &#x6216;&#x66F4;&#x9AD8;&#x7248;&#x672C;&#x4E0D;&#x517C;&#x5BB9;&#xFF0C;&#x56E0;&#x6B64;&#x6C38;&#x8FDC;&#x4E0D;&#x5E94;&#x5728; <code>required_providers</code> &#x5757;&#x4E2D;&#x58F0;&#x660E;&#x3002;</p>
<h2 id="provider-&#x7684;&#x914D;&#x7F6E;"><a name="provider-&#x7684;&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#provider-&#x7684;&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.5. Provider &#x7684;&#x914D;&#x7F6E;</h2>
<p>Provider &#x7684;&#x914D;&#x7F6E;&#x662F;&#x58F0;&#x660E;&#x5728;&#x6839;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x4E00;&#x7EC4; Terraform &#x914D;&#x7F6E;&#x3002;&#xFF08;&#x5B50;&#x6A21;&#x5757;&#x63A5;&#x6536;&#x6765;&#x81EA;&#x4E8E;&#x6839;&#x6A21;&#x5757;&#x7684; Provider &#x914D;&#x7F6E;&#xFF0C;&#x66F4;&#x591A;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x53C2;&#x9605;<a href="4.2.&#x4F7F;&#x7528;&#x6A21;&#x5757;.html#&#x663E;&#x5F0F;&#x4F20;&#x9012;-provider">&#x6A21;&#x5757;&#x7684; <code>provider</code> &#x5143;&#x53C2;&#x6570;</a>&#xFF09;</p>
<p>&#x4E00;&#x4E2A; Provider &#x914D;&#x7F6E;&#x662F;&#x901A;&#x8FC7; <code>provider</code> &#x5757;&#x6765;&#x521B;&#x5EFA;&#x7684;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">provider<span class="token type variable"> &quot;google&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">project</span> <span class="token punctuation">=</span> <span class="token string">&quot;acme-app&quot;</span>
  <span class="token property">region</span>  <span class="token punctuation">=</span> <span class="token string">&quot;us-central1&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5757;&#x5934;&#x90E8;&#x8BBE;&#x7F6E;&#x7684;&#x540D;&#x79F0;&#xFF08;&#x4F8B;&#x5B50;&#x4E2D;&#x7684; <code>&quot;google&quot;</code>&#xFF09;&#x5C31;&#x662F;&#x8981;&#x914D;&#x7F6E;&#x7684; Provider &#x7684;<a href="terraform/language/providers/requirements#local-names">Local Name</a>&#x3002;&#x8FD9;&#x4E2A; Provider &#x5FC5;&#x987B;&#x5DF2;&#x5728; <code>required_providers</code> &#x5757;&#x4E2D;&#x58F0;&#x660E;&#x3002;</p>
<p>&#x5757;&#x4F53;&#xFF08;<code>{</code> &#x548C; <code>}</code> &#x4E2D;&#x95F4;&#x7684;&#x5185;&#x5BB9;&#xFF09;&#x5305;&#x542B;&#x4E86; Provider &#x7684;&#x914D;&#x7F6E;&#x53C2;&#x6570;&#x3002;&#x8FD9;&#x4E9B;&#x53C2;&#x6570;&#x5927;&#x591A;&#x6570;&#x662F;&#x7531; Provider &#x81EA;&#x5DF1;&#x5B9A;&#x4E49;&#x7684;&#xFF1B;&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;<code>project</code> &#x548C; <code>region</code> &#x90FD;&#x662F; <code>google</code> Provider &#x7279;&#x6709;&#x7684;&#x3002;</p>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x8FD9;&#x4E9B;&#x914D;&#x7F6E;&#x7684;&#x503C;&#x5F53;&#x4E2D;&#x4F7F;&#x7528;<a href="3.8.&#x8868;&#x8FBE;&#x5F0F;.html">&#x8868;&#x8FBE;&#x5F0F;</a>&#xFF0C;&#x4F46;&#x662F;&#x53EA;&#x80FD;&#x5F15;&#x7528;&#x5728;&#x914D;&#x7F6E; Provider &#x65F6;&#x5DF2;&#x77E5;&#x7684;&#x503C;&#x3002;&#x8FD9;&#x610F;&#x5473;&#x7740;&#x4F60;&#x53EF;&#x4EE5;&#x5B89;&#x5168;&#x5730;&#x5F15;&#x7528;&#x8F93;&#x5165;&#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x80FD;&#x5F15;&#x7528;&#x4ECE; <code>resource</code> &#x8FD4;&#x56DE;&#x7684;&#x5C5E;&#x6027;&#xFF08;&#x4E00;&#x4E2A;&#x4F8B;&#x5916;&#x662F;&#x76F4;&#x63A5;&#x5728;&#x914D;&#x7F6E;&#x4E2D;&#x786C;&#x7F16;&#x7801;&#x7684; <code>resource</code> &#x53C2;&#x6570;&#xFF09;&#x3002;</p>
<p>&#x4E00;&#x4E2A; Provider &#x7684;&#x6587;&#x6863;&#x5E94;&#x8BE5;&#x5217;&#x51FA;&#x5B83;&#x6240;&#x9700;&#x8981;&#x7684;&#x914D;&#x7F6E;&#x53C2;&#x6570;&#x3002;&#x5BF9;&#x90A3;&#x4E9B;&#x6CE8;&#x518C;&#x5728; <a href="https://registry.terraform.io" target="_blank">Terraform Registry</a> &#x4E0A;&#x7684; Provider &#x6765;&#x8BF4;&#xFF0C;&#x6BCF;&#x4E2A; Provider &#x7684;&#x9875;&#x9762;&#x4E0A;&#x90FD;&#x6709;&#x7248;&#x672C;&#x5316;&#x7684;&#x6587;&#x6863;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; Provider &#x9875;&#x5934;&#x7684; &quot;Documentation&quot; &#x94FE;&#x63A5;&#x8BBF;&#x95EE;&#x3002;</p>
<p>&#x4E00;&#x4E9B; Provider &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#xFF08;&#x6216;&#x662F;&#x5176;&#x4ED6;&#x66FF;&#x4EE3;&#x914D;&#x7F6E;&#x6E90;&#xFF0C;&#x4F8B;&#x5982; AWS &#x7684;&#x865A;&#x62DF;&#x673A;&#x5B9E;&#x4F8B; Profile&#xFF09;&#x4F5C;&#x4E3A;&#x67D0;&#x4E9B;&#x914D;&#x7F6E;&#x53C2;&#x6570;&#x7684;&#x503C;&#xFF1B;&#x6211;&#x4EEC;&#x5EFA;&#x8BAE;&#x5C3D;&#x53EF;&#x80FD;&#x4F7F;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x6765;&#x907F;&#x514D;&#x5C06;&#x51ED;&#x8BC1;&#x4FDD;&#x5B58;&#x4E8E;&#x7248;&#x672C;&#x63A7;&#x5236;&#x7684; Terraform &#x4EE3;&#x7801;&#x4E2D;&#x3002;</p>
<p>There are also two &quot;meta-arguments&quot; that are defined by Terraform itself
and available for all <code>provider</code> blocks:</p>
<p>&#x6709;&#x4E24;&#x4E2A;&#x7531; Terraform &#x81EA;&#x8EAB;&#x5B9A;&#x4E49;&#x7684;&#x201C;&#x5143;&#x53C2;&#x6570;&#x201D;&#xFF0C;&#x5BF9;&#x6240;&#x6709; <code>provider</code> &#x5757;&#x90FD;&#x53EF;&#x7528;&#xFF1A;</p>
<ul>
<li><a href="#&#x591A;-provider-&#x5B9E;&#x4F8B;"><code>alias</code>&#xFF0C;&#x7528;&#x4EE5;&#x4E3A;&#x4E0D;&#x540C;&#x7684; <code>resource</code> &#x5757;&#x914D;&#x7F6E;&#x53C2;&#x6570;&#x4E0D;&#x540C;&#x7684;&#x540C;&#x7C7B; Provider &#x5B9E;&#x4F8B;</a></li>
<li><code>version</code>&#xFF0C; &#x5E9F;&#x5F03;&#xFF0C;&#x4E0D;&#x63A8;&#x8350;&#x4F7F;&#x7528;&#xFF0C;&#x73B0;&#x5728;&#x8BF7;&#x4F7F;&#x7528; <a href="#provider-&#x7684;&#x58F0;&#x660E;"><code>required_providers</code></a></li>
</ul>
<p>&#x4E0E; Terraform &#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x8BB8;&#x591A;&#x5176;&#x4ED6;&#x5BF9;&#x8C61;&#x4E0D;&#x540C;&#xFF0C;&#x5982;&#x679C; <code>provider</code> &#x5757;&#x7684;&#x5185;&#x5BB9;&#x4E3A;&#x7A7A;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x8BE5;&#x5757;&#x3002;Terraform &#x5047;&#x5B9A;&#x672A;&#x663E;&#x5F0F;&#x914D;&#x7F6E;&#x7684;&#x4EFB;&#x4F55; Provider &#x7A0B;&#x5E8F;&#x90FD;&#x5177;&#x6709;&#x7A7A;&#x7684;&#x9ED8;&#x8BA4;&#x914D;&#x7F6E;&#x3002;</p>
<h2 id="&#x591A;-provider-&#x5B9E;&#x4F8B;"><a name="&#x591A;-provider-&#x5B9E;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#&#x591A;-provider-&#x5B9E;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.6. &#x591A; Provider &#x5B9E;&#x4F8B;</h2>
<p><code>provider</code> &#x5757;&#x58F0;&#x660E;&#x4E86; <code>aws</code> &#x8FD9;&#x4E2A; Provider &#x6240;&#x9700;&#x8981;&#x7684;&#x5404;&#x9879;&#x914D;&#x7F6E;&#x3002;&#x5728;&#x4E0A;&#x6587;&#x7684;&#x4EE3;&#x7801;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;<code>provider &quot;aws&quot;</code>&#x548C;<code>required_providers</code>&#x4E2D;<code>aws = {...}</code>&#x5757;&#x91CC;&#x7684;<code>aws</code>&#xFF0C;&#x90FD;&#x662F; Provider &#x7684; Local Name&#xFF0C;&#x4E00;&#x4E2A; Local Name &#x662F;&#x5728;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x5BF9;&#x4E00;&#x4E2A; Provider &#x7684;&#x552F;&#x4E00;&#x7684;&#x6807;&#x8BC6;&#x3002;</p>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x9009;&#x62E9;&#x4E3A;&#x540C;&#x4E00;&#x4E2A; Provider &#x5B9A;&#x4E49;&#x591A;&#x4E2A;&#x914D;&#x7F6E;&#xFF0C;&#x5E76;&#x4E14;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x6BCF;&#x4E2A;&#x8D44;&#x6E90;&#x6216;&#x6BCF;&#x4E2A;&#x6A21;&#x5757;&#x6765;&#x9009;&#x62E9;&#x4F7F;&#x7528;&#x54EA;&#x4E00;&#x4E2A;&#x3002;&#x8FD9;&#x4E3B;&#x8981;&#x662F;&#x4E3A;&#x4E86;&#x652F;&#x6301;&#x4E91;&#x5E73;&#x53F0;&#x7684;&#x591A;&#x4E2A;&#x533A;&#x57DF;&#xFF1B;&#x5176;&#x4ED6;&#x4F8B;&#x5B50;&#x5305;&#x62EC;&#x9488;&#x5BF9;&#x591A;&#x4E2A; Docker &#x4E3B;&#x673A;&#xFF0C;&#x591A;&#x4E2A; Consul &#x4E3B;&#x673A;&#x7B49;&#x3002;</p>
<p>&#x8981;&#x4E3A;&#x67D0;&#x4E00;&#x4E2A; Provider &#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x914D;&#x7F6E;&#xFF0C;&#x5305;&#x62EC;&#x5177;&#x6709;&#x76F8;&#x540C;&#x63D0;&#x4F9B;&#x8005;&#x540D;&#x79F0;&#x7684;&#x591A;&#x4E2A; <code>provider</code> &#x5757;&#x3002;&#x5BF9;&#x4E8E;&#x6BCF;&#x4E2A;&#x989D;&#x5916;&#x7684;&#x975E;&#x9ED8;&#x8BA4;&#x914D;&#x7F6E;&#xFF0C;&#x4F7F;&#x7528; <code>alias</code> &#x5143;&#x53C2;&#x6570;&#x63D0;&#x4F9B;&#x989D;&#x5916;&#x7684;&#x540D;&#x79F0;&#x6BB5;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token comment"># The default provider configuration; resources that begin with `aws_` will use</span>
<span class="token comment"># it as the default, and it can be referenced as `aws`.</span>
<span class="token keyword">provider<span class="token type variable"> &quot;aws&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">region</span> <span class="token punctuation">=</span> <span class="token string">&quot;us-east-1&quot;</span>
<span class="token punctuation">}</span>

<span class="token comment"># Additional provider configuration for west coast region; resources can</span>
<span class="token comment"># reference this as `aws.west`.</span>
<span class="token keyword">provider<span class="token type variable"> &quot;aws&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">alias</span>  <span class="token punctuation">=</span> <span class="token string">&quot;west&quot;</span>
  <span class="token property">region</span> <span class="token punctuation">=</span> <span class="token string">&quot;us-west-2&quot;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728;&#x6A21;&#x5757;&#x5185;&#x58F0;&#x660E;&#x914D;&#x7F6E; <code>alias</code> &#x4EE5;&#x4ECE;&#x7236;&#x6A21;&#x5757;&#x63A5;&#x6536;&#x5907;&#x7528;&#x7684; <code>provider</code> &#x914D;&#x7F6E;&#xFF0C;&#x9700;&#x8981;&#x5728;&#x8BE5; <code>provider</code> &#x7684; <code>required_providers</code> &#x6761;&#x76EE;&#x4E2D;&#x6DFB;&#x52A0; <code>configuration_aliases</code> &#x53C2;&#x6570;&#x3002;&#x4EE5;&#x4E0B;&#x793A;&#x4F8B;&#x5728;&#x5305;&#x542B;&#x7684;&#x6A21;&#x5757;&#x4E2D;&#x58F0;&#x660E;&#x4E86; <code>mycloud</code> &#x548C; <code>mycloud.alternate</code> &#x7684; <code>provider</code> &#x914D;&#x7F6E;&#x540D;&#x79F0;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">terraform</span> <span class="token punctuation">{</span>
  <span class="token keyword">required_providers</span> <span class="token punctuation">{</span>
    <span class="token property">mycloud</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
      <span class="token property">source</span>  <span class="token punctuation">=</span> <span class="token string">&quot;mycorp/mycloud&quot;</span>
      <span class="token property">version</span> <span class="token punctuation">=</span> <span class="token string">&quot;~&gt; 1.0&quot;</span>
      <span class="token property">configuration_aliases</span> <span class="token punctuation">=</span> <span class="token punctuation">[</span> mycloud.alternate <span class="token punctuation">]</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x9ED8;&#x8BA4;-provider-&#x914D;&#x7F6E;"><a name="&#x9ED8;&#x8BA4;-provider-&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#&#x9ED8;&#x8BA4;-provider-&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.6.1. &#x9ED8;&#x8BA4; Provider &#x914D;&#x7F6E;</h3>
<p>&#x6CA1;&#x6709; <code>alias</code> &#x53C2;&#x6570;&#x7684; <code>provider</code> &#x5757;&#x662F;&#x8BE5; provider &#x7684; <em>&#x9ED8;&#x8BA4;</em> &#x914D;&#x7F6E;&#x3002;&#x672A;&#x8BBE;&#x7F6E; <code>provider</code> &#x5143;&#x53C2;&#x6570;&#x7684;&#x8D44;&#x6E90;&#x5C06;&#x4F7F;&#x7528;&#x4E0E;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x540D;&#x79F0;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5355;&#x8BCD;&#x5339;&#x914D;&#x7684;&#x9ED8;&#x8BA4; provider &#x914D;&#x7F6E;&#x3002;&#xFF08;&#x4F8B;&#x5982;&#xFF0C;&#x9664;&#x975E;&#x53E6;&#x6709;&#x8BF4;&#x660E;&#xFF0C;&#x5426;&#x5219; <code>aws_instance</code> &#x8D44;&#x6E90;&#x5C06;&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x7684; <code>aws</code> provider &#x914D;&#x7F6E;&#x3002;&#xFF09;</p>
<p>&#x5982;&#x679C; provider &#x7684;&#x6BCF;&#x4E2A;&#x663E;&#x5F0F;&#x914D;&#x7F6E;&#x90FD;&#x6709;&#x522B;&#x540D;&#xFF0C;Terraform &#x5C06;&#x4F7F;&#x7528;&#x9690;&#x542B;&#x7684;&#x7A7A;&#x914D;&#x7F6E;&#x4F5C;&#x4E3A;&#x8BE5; provider &#x7684;&#x9ED8;&#x8BA4;&#x914D;&#x7F6E;&#x3002;&#xFF08;&#x5982;&#x679C; provider &#x6709;&#x4EFB;&#x4F55;&#x5FC5;&#x9700;&#x7684;&#x914D;&#x7F6E;&#x53C2;&#x6570;&#xFF0C;&#x5F53;&#x8D44;&#x6E90;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;&#x7A7A;&#x914D;&#x7F6E;&#x65F6;&#xFF0C;Terraform &#x5C06;&#x5F15;&#x53D1;&#x9519;&#x8BEF;&#x3002;&#xFF09;</p>
<h3 id="&#x5F15;&#x7528;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;"><a name="&#x5F15;&#x7528;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x7528;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.6.2. &#x5F15;&#x7528;&#x5907;&#x7528; Provider &#x914D;&#x7F6E;</h3>
<p>&#x5F53; Terraform &#x9700;&#x8981; provider &#x914D;&#x7F6E;&#x7684;&#x540D;&#x79F0;&#x65F6;&#xFF0C;&#x5B83;&#x671F;&#x671B;&#x7684;&#x662F; <code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>PROVIDER</span> <span class="token attr-name">NAME</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ALIAS</span><span class="token punctuation">&gt;</span></span></code> &#x5F62;&#x5F0F;&#x7684;&#x5F15;&#x7528;&#x3002;&#x5728;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;<code>aws.west</code> &#x5C06;&#x5F15;&#x7528; <code>us-west-2</code> &#x533A;&#x57DF;&#x7684; provider&#x3002;</p>
<p>&#x8FD9;&#x4E9B;&#x5F15;&#x7528;&#x662F;&#x7279;&#x6B8A;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x3002;&#x50CF;&#x5BF9;&#x5176;&#x4ED6;&#x547D;&#x540D;&#x5B9E;&#x4F53;&#xFF08;&#x4F8B;&#x5982; <code>var.image_id</code>&#xFF09;&#x7684;&#x5F15;&#x7528;&#x4E00;&#x6837;&#xFF0C;&#x5B83;&#x4EEC;&#x4E0D;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x5F15;&#x53F7;&#x3002;&#x4F46;&#x662F;&#x5B83;&#x4EEC;&#x53EA;&#x5728; <code>resource</code>&#x3001;<code>data</code> &#x548C; <code>module</code> &#x5757;&#x7684;&#x7279;&#x5B9A;&#x5143;&#x53C2;&#x6570;&#x4E2D;&#x6709;&#x6548;&#xFF0C;&#x4E0D;&#x80FD;&#x5728;&#x4EFB;&#x610F;&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="&#x9009;&#x62E9;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;"><a name="&#x9009;&#x62E9;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#&#x9009;&#x62E9;&#x5907;&#x7528;-provider-&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1.1.6.3. &#x9009;&#x62E9;&#x5907;&#x7528; Provider &#x914D;&#x7F6E;</h3>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x8D44;&#x6E90;&#x4F7F;&#x7528;&#x4ECE;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x540D;&#x79F0;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5355;&#x8BCD;&#x63A8;&#x65AD;&#x51FA;&#x7684;&#x9ED8;&#x8BA4; provider &#x914D;&#x7F6E;&#xFF08;&#x6CA1;&#x6709; <code>alias</code> &#x53C2;&#x6570;&#x7684;&#x914D;&#x7F6E;&#xFF09;&#x3002;</p>
<p>&#x8981;&#x4E3A;&#x8D44;&#x6E90;&#x6216;&#x6570;&#x636E;&#x6E90;&#x6307;&#x5B9A;&#x5907;&#x7528; provider &#x914D;&#x7F6E;&#xFF0C;&#x5C06;&#x5176; <code>provider</code> &#x5143;&#x53C2;&#x6570;&#x8BBE;&#x7F6E;&#x4E3A; <code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>PROVIDER</span> <span class="token attr-name">NAME</span><span class="token punctuation">&gt;</span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>ALIAS</span><span class="token punctuation">&gt;</span></span></code> &#x5F15;&#x7528;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">resource <span class="token type variable">&quot;aws_instance&quot;</span></span> <span class="token string">&quot;foo&quot;</span> <span class="token punctuation">{</span>
  <span class="token property">provider</span> <span class="token punctuation">=</span> aws.west

  <span class="token comment"># ...</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8981;&#x4E3A;&#x5B50;&#x6A21;&#x5757;&#x6307;&#x5B9A;&#x5907;&#x7528; provider &#x914D;&#x7F6E;&#xFF0C;&#x4F7F;&#x7528;&#x5176; <code>providers</code> &#x5143;&#x53C2;&#x6570;&#x6307;&#x5B9A;&#x5E94;&#x5C06;&#x54EA;&#x4E9B; provider &#x914D;&#x7F6E;&#x6620;&#x5C04;&#x5230;&#x6A21;&#x5757;&#x5185;&#x7684;&#x54EA;&#x4E9B;&#x672C;&#x5730; provider &#x540D;&#x79F0;&#xFF1A;</p>
<pre class="language-"><code class="lang-hcl"><span class="token keyword">module<span class="token type variable"> &quot;aws_vpc&quot; </span></span><span class="token punctuation">{</span>
  <span class="token property">source</span> <span class="token punctuation">=</span> <span class="token string">&quot;./aws_vpc&quot;</span>
  <span class="token property">providers</span> <span class="token punctuation">=</span> <span class="token punctuation">{</span>
    <span class="token property">aws</span> <span class="token punctuation">=</span> aws.west
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5728;&#x4F20;&#x9012; provider &#x65F6;&#xFF0C;&#x6A21;&#x5757;&#x6709;&#x4E00;&#x4E9B;&#x7279;&#x6B8A;&#x8981;&#x6C42;&#xFF1B;&#x6709;&#x5173;&#x66F4;&#x591A;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x53C2;&#x89C1; <a href="terraform/language/meta-arguments/module-providers">&#x6A21;&#x5757; <code>providers</code> &#x5143;&#x53C2;&#x6570;</a>&#x3002;&#x5728;&#x5927;&#x591A;&#x6570;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x53EA;&#x6709; <em>&#x6839;&#x6A21;&#x5757;</em> &#x5E94;&#x5B9A;&#x4E49; provider &#x914D;&#x7F6E;&#xFF0C;&#x6240;&#x6709;&#x5B50;&#x6A21;&#x5757;&#x90FD;&#x5E94;&#x4ECE;&#x5176;&#x7236;&#x6A21;&#x5757;&#x83B7;&#x53D6;&#x5176; provider &#x914D;&#x7F6E;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="2.2.Terraform基础概念——状态管理.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 状态管理">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Provider","level":"1.3.1","depth":2,"next":{"title":"状态管理","level":"1.3.2","depth":2,"path":"2.2.Terraform基础概念——状态管理.md","ref":"./2.2.Terraform基础概念——状态管理.md","articles":[]},"previous":{"title":"Terraform基础概念","level":"1.3","depth":1,"ref":"","articles":[{"title":"Provider","level":"1.3.1","depth":2,"path":"2.1.Terraform基础概念——Provider.md","ref":"./2.1.Terraform基础概念——Provider.md","articles":[]},{"title":"状态管理","level":"1.3.2","depth":2,"path":"2.2.Terraform基础概念——状态管理.md","ref":"./2.2.Terraform基础概念——状态管理.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-highlight","prism","prism-themes","fontsettings","sharing","-lunr","-search","search-pro","livereload","image-captions","sitemap-general","anchor-navigation-ex"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"css":["prism-themes/themes/prism-vsc-dark-plus.css"],"lang":{"shell":"bash","cmd":"bash"}},"livereload":{},"search-pro":{},"sitemap-general":{"prefix":"https://lonegunmanb.github.io/introduction-terraform/"},"fontsettings":{"family":"sans","size":2,"theme":"white"},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"prism-themes":{},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"image-captions":{"caption":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"大可不加冰","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[{"backlink":"index.html#fig1.1.1","level":"1.1","list_caption":"Figure: Nomad、Consul、Vault、Terraform 组成的 HashiStack","alt":"Nomad、Consul、Vault、Terraform 组成的 HashiStack","nro":1,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-13/1605243540985-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Nomad、Consul、Vault、Terraform 组成的 HashiStack","attributes":{},"skip":false,"key":"1.1.1"},{"backlink":"index.html#fig1.1.2","level":"1.1","list_caption":"Figure: Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","alt":"Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","nro":2,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-12-23/1608689176373-image.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform 著名教材《Terraform Up & Running》，建议直接阅读第二版","attributes":{},"skip":false,"key":"1.1.2"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.1","level":"1.3.1","list_caption":"Figure: Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","alt":"Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","nro":3,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605496195438-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform通过RPC调用插件，插件代码通过调用SDK操作远程资源","attributes":{},"skip":false,"key":"1.3.1.1"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.2","level":"1.3.1","list_caption":"Figure: registry.terraform.io上的插件页面","alt":"registry.terraform.io上的插件页面","nro":4,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-19/1605799350775-image.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"registry.terraform.io上的插件页面","attributes":{},"skip":false,"key":"1.3.1.2"},{"backlink":"./2.1.Terraform基础概念——Provider.html#fig1.3.1.3","level":"1.3.1","list_caption":"Figure: registry.terraform.io的搜索页面","alt":"registry.terraform.io的搜索页面","nro":5,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-16/1605498907942-image.png","index":3,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"registry.terraform.io的搜索页面","attributes":{},"skip":false,"key":"1.3.1.3"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.1","level":"1.3.2","list_caption":"Figure: Consul的GUI界面","alt":"Consul的GUI界面","nro":6,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220224455.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul的GUI界面","attributes":{},"skip":false,"key":"1.3.2.1"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.2","level":"1.3.2","list_caption":"Figure: Consul 中可以看到名为 `localstack-aws` 的键","alt":"Consul 中可以看到名为 `localstack-aws` 的键","nro":7,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230042.png","index":2,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul 中可以看到名为 `localstack-aws` 的键","attributes":{},"skip":false,"key":"1.3.2.2"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.3","level":"1.3.2","list_caption":"Figure: 键的内容","alt":"键的内容","nro":8,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230136.png","index":3,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"键的内容","attributes":{},"skip":false,"key":"1.3.2.3"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.4","level":"1.3.2","list_caption":"Figure: 键依然存在","alt":"键依然存在","nro":9,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230312.png","index":4,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"键依然存在","attributes":{},"skip":false,"key":"1.3.2.4"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.5","level":"1.3.2","list_caption":"Figure: 内容已被清空","alt":"内容已被清空","nro":10,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240220230350.png","index":5,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"内容已被清空","attributes":{},"skip":false,"key":"1.3.2.5"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.6","level":"1.3.2","list_caption":"Figure: 多了一个同名的文件夹","alt":"多了一个同名的文件夹","nro":11,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225100309.png","index":6,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"多了一个同名的文件夹","attributes":{},"skip":false,"key":"1.3.2.6"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.7","level":"1.3.2","list_caption":"Figure: localstack-aws 文件夹内部","alt":"localstack-aws 文件夹内部","nro":12,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225100354.png","index":7,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"localstack-aws 文件夹内部","attributes":{},"skip":false,"key":"1.3.2.7"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.8","level":"1.3.2","list_caption":"Figure: `.lock` 内容","alt":"`.lock` 内容","nro":13,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180803.png","index":8,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`.lock` 内容","attributes":{},"skip":false,"key":"1.3.2.8"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.9","level":"1.3.2","list_caption":"Figure: `.lockinfo` 内容","alt":"`.lockinfo` 内容","nro":14,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180852.png","index":9,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`.lockinfo` 内容","attributes":{},"skip":false,"key":"1.3.2.9"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.10","level":"1.3.2","list_caption":"Figure: 重新访问Consul","alt":"重新访问Consul","nro":15,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225101100.png","index":10,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"重新访问Consul","attributes":{},"skip":false,"key":"1.3.2.10"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.11","level":"1.3.2","list_caption":"Figure: 将代码复制到不同的文件夹中保存","alt":"将代码复制到不同的文件夹中保存","nro":16,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-17/1605571444613-image.png","index":11,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"将代码复制到不同的文件夹中保存","attributes":{},"skip":false,"key":"1.3.2.11"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.12","level":"1.3.2","list_caption":"Figure: 重新访问 Consul，目前有一个键","alt":"重新访问 Consul，目前有一个键","nro":17,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225174932.png","index":12,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"重新访问 Consul，目前有一个键","attributes":{},"skip":false,"key":"1.3.2.12"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.13","level":"1.3.2","list_caption":"Figure: Consul 中多了一个 `localstack-aws-env:feature1`","alt":"Consul 中多了一个 `localstack-aws-env:feature1`","nro":18,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225175538.png","index":13,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Consul 中多了一个 `localstack-aws-env:feature1`","attributes":{},"skip":false,"key":"1.3.2.13"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.14","level":"1.3.2","list_caption":"Figure: 此时 `localstack-aws-env:feature1` 的内容","alt":"此时 `localstack-aws-env:feature1` 的内容","nro":19,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225175806.png","index":14,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"此时 `localstack-aws-env:feature1` 的内容","attributes":{},"skip":false,"key":"1.3.2.14"},{"backlink":"./2.2.Terraform基础概念——状态管理.html#fig1.3.2.15","level":"1.3.2","list_caption":"Figure: `localstack-aws-env:feature1` 被删除了","alt":"`localstack-aws-env:feature1` 被删除了","nro":20,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/20240225180126.png","index":15,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"`localstack-aws-env:feature1` 被删除了","attributes":{},"skip":false,"key":"1.3.2.15"},{"backlink":"./5.10.graph.html#fig1.6.10.1","level":"1.6.10","list_caption":"Figure: 生成的依赖图","alt":"生成的依赖图","nro":21,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2020-11-25/1606272727693-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"生成的依赖图","attributes":{},"skip":false,"key":"1.6.10.1"},{"backlink":"8.CloudPosse最佳实践.html#fig1.9.1","level":"1.9","list_caption":"Figure: Terraform 输出值的命名要对称","alt":"Terraform 输出值的命名要对称","nro":22,"url":"https://raw.githubusercontent.com/lonegunmanb/introduction-to-terraform-pic/master/2021-11-28/1638086002974-image.png","index":1,"caption_template":"图 _PAGE_LEVEL_/_PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"Terraform 输出值的命名要对称","attributes":{},"skip":false,"key":"1.9.1"}]},"title":"《Terraform入门教程》","gitbook":"*"},"file":{"path":"2.1.Terraform基础概念——Provider.md","mtime":"2024-05-25T00:11:31.200Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-06-24T12:39:39.308Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    

    </body>
</html>

